<?php
header('Content-type:text/html;charset=utf-8');

//包含数据库配置
include '../../public/peizhi.php';

//包含函数
include '../../public/func.php';

//调用函数
$link = db();

//接值并判断要删除的分区ID
if(empty($_REQUEST['fq_id'])){
	exit('<script>alert("没有分区或没有选择分区");window.location.href="show.php";</script>');
}

$fq_id = $_REQUEST['fq_id'];

//是否批量删除
if(is_array($fq_id)){
		$newid = implode(',',$fq_id);
	}else{
		$newid = $fq_id;
	}	
	
//判断分区下是否有板块
$lsql = " select bk_id from bankuai where fq_id in({$newid})";
$lres = mysqli_query($link,$lsql);
if($lres && mysqli_num_rows($lres)){
	exit('<script>alert("该分区下有板块,不能被删除");window.location.href="show.php";</script>');
}else{
		$sql = "delete from fenqu where id in({$newid})";
	}

//判断执行SQL语句
if($res = mysqli_query($link,$sql)){
	echo '<script>alert("删除分区成功");window.location.href="show.php";</script>';
}else{
	echo '<script>alert("删除分区失败");window.location.href="show.php";</script>';
}

//释放结果
mysqli_free_result($lres);

//关闭数据库连接
mysqli_close($link);


